import { defineStore } from 'pinia';
// @ts-ignore
import { store } from '@/stores';

interface IAsyncRouteStore {
  keepAliveComponentList: string[];
}
export const useAsyncRouteStore = defineStore({
  id: 'app-async-route',
  state: (): IAsyncRouteStore => ({
    keepAliveComponentList: [],
  }),
  getters: {
    getKeepAliveComponentList(): string[] {
      return this.keepAliveComponentList;
    },
  },
  actions: {
    setKeepAliveComponentList(list: string[]) {
      this.keepAliveComponentList = list;
    },
  },
  persist: {
    key: 'PINIA-ASYNC-ROUTE-STORE',
    paths: ['keepAliveComponentList'],
  },
});

export const useAsyncRouteStoreOut = () => useAsyncRouteStore(store);
